//
//  A-2-ViewController.m
//  页面之间传值
//
//  Created by MAC on 2018/8/27.
//  Copyright © 2018年 MAC. All rights reserved.
//

#import "A-2-ViewController.h"

@interface A_2_ViewController ()
//声明全局指针，UIButton、UILabel
@property (nonatomic,strong) UILabel *label;
@property (nonatomic,strong) UIButton *btn;
@end

@implementation A_2_ViewController
//UILabel的懒加载
- (UILabel *)label
{
    if (_label == nil) {
        _label = [[UILabel alloc]initWithFrame:CGRectMake((self.view.frame.size.width-200)/2, 100, 200, 40)];
        _label.backgroundColor = [UIColor blackColor];
        _label.textColor = [UIColor whiteColor];
        _label.font = [UIFont systemFontOfSize:20];
        //页面一zhiong
        _label.text = self.str;
    }
    return _label;
}
//UIButton的懒加载
- (UIButton *)btn
{
    if (_btn == nil) {
        _btn = [UIButton buttonWithType:UIButtonTypeCustom];
        _btn.backgroundColor = [UIColor redColor];
        _btn.frame = CGRectMake((self.view.frame.size.width-200)/2, _label.frame.origin.y+_label.frame.size.height+40, 200, 40);
        [_btn setTitle:@"跳转页面一" forState:UIControlStateNormal];
        [_btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _btn.titleLabel.font = [UIFont systemFontOfSize:20];
        [_btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _btn;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    //把UIButton、UILabel 添加到view视图上
    [self.view addSubview:self.label];
    [self.view addSubview:self.btn];
}

//返回A页面
- (void)btnClick
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
